//
//  TrailerTableViewCell.m
//  Movie
//
//  Created by cjy on 16/3/28.
//  Copyright © 2016年 HY. All rights reserved.
//

#import "TrailerTableViewCell.h"
#import "ModelTrailer.h"
#import <UIImageView+WebCache.h>
@implementation TrailerTableViewCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubview];
    
    }
    
    return self;
}


- (void)createSubview{
    
    self.imageV = [[UIImageView alloc]init];
    [self.contentView addSubview:self.imageV];
    
    
    self.title = [[UILabel alloc]init];
    [self.imageV addSubview:self.title];
    
    
    self.artistName = [[UILabel alloc]init];
    [self.imageV addSubview:self.artistName];
    
    
    self.totalViews = [[UILabel alloc]init];
    [self.imageV addSubview:self.totalViews];
    
}


- (void)layoutSubviews{
 
    [super layoutSubviews];

    self.imageV.frame = CGRectMake(0, 0, self.contentView.frame.size.width, [UIScreen mainScreen].bounds.size.height / 3 - 20);

    self.title.frame = CGRectMake(15, self.contentView.frame.size.height - 50, self.contentView.frame.size.width, 10);
    self.title.shadowColor = [UIColor blackColor];
    self.title.shadowOffset = CGSizeMake(0.3, 0.5);
    
    self.artistName.frame = CGRectMake(15, self.contentView.frame.size.height - 35, self.contentView.frame.size.width, 10);
    self.artistName.shadowColor = [UIColor blackColor];
    self.artistName.shadowOffset = CGSizeMake(0.5, 0.5);
    
    self.totalViews.frame = CGRectMake(15, self.contentView.frame.size.height - 20, self.contentView.frame.size.width, 10);
    self.totalViews.shadowColor = [UIColor blackColor];
    self.totalViews.shadowOffset = CGSizeMake(0.5, 0.5);
}





- (void)passModel:(ModelTrailer *)model{
    
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:model.posterPic] placeholderImage:[UIImage imageNamed:@"zwt"]];
    
    // 标题
    self.title.text = [NSString stringWithFormat:@"%@",model.title];
    self.title.font = [UIFont boldSystemFontOfSize:14];
    self.title.textColor = [UIColor whiteColor];
    
    // 演唱者
    self.artistName.text = [NSString stringWithFormat:@"%@",model.artistName];
    self.artistName.font = [UIFont systemFontOfSize:13];
    self.artistName.textColor = [UIColor greenColor];
    
    // 播放次数
    self.totalViews.text = [NSString stringWithFormat:@"播放次数%@",model.totalViews];
    self.totalViews.font = [UIFont systemFontOfSize:13];
    self.totalViews.textColor = [UIColor  whiteColor];

}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
